home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / bbs / WWBBSDoors.lha / WWBBS / rexxDoors / Grin_du_Jour.rexx < prev    next >
OS/2 REXX Batch file  |  1995-04-25  |  2KB  |  62 lines

  1. /* $VER: Grin_du_Jour.rexx 6.3 (28.8.93)
  2.     copyright 1991 Richard Lee Stockton
  3.           FREELY DISTRIBUTABLE
  4.  
  5. This will manage grin (cookie, fortune, etc.) files up to about 12 MEG
  6.  
  7. */
  8.  
  9. FF='0C'x  /* FormFeed */
  10. CR='0D'x  /* Carraige Return */
  11. SIGNAL ON BREAK_C
  12. SIGNAL ON BREAK_E
  13.  
  14. ARG name .
  15.  
  16. /* Open the support library if it is not already open. */
  17. if ~show('L',"rexxsupport.library") then do
  18.     addlib('rexxsupport.library',0,-30,0)
  19.      end
  20.  
  21. bbspath=GETCLIP('BBS_path')
  22. filename=bbspath'rexxDoors/Data/Grins' /* Formfeed separated text */
  23. size=WORD(STATEF(filename),2)
  24. fragment=size/3000
  25.  
  26. x=OPEN(f,'RAM:DUMMY','W')                /* write to a dummy file */
  27. IF x=0 THEN EXIT(20);
  28. CALL WRITELN(f,'dummy')
  29. CALL CLOSE(f)
  30. micros=WORD(STATEF('RAM:DUMMY'),7)        /*  0 >= micros < 3000  */
  31. location=fragment*micros
  32. IF fragment>1000 THEN
  33.   location=location+fragment*RIGHT(DATE('I'),2)/100
  34. ELSE IF fragment>100 THEN
  35.   location=location+fragment*RIGHT(DATE('I'),1)/10
  36. location=TRUNC(location)
  37. IF location>size THEN location=micros
  38.  
  39. x=OPEN(f,filename,'R')
  40. IF x=0 THEN RETURN(10);
  41. CALL SEEK(f,location,'B')            /* point to the random place */
  42. line=''
  43. DO WHILE line~=FF & ~EOF(f)        /* find the start (a formfeed) */
  44.   line=READLN(f)
  45. END
  46. count=0
  47. line=''
  48. IF ~EOF(f) THEN      /* if EOF then must be right at end. missed! */
  49.   DO WHILE line~=FF & ~EOF(f)         /* otherwise, show the page */
  50.     line=READLN(f)
  51.     IF ~EOF(f) & line~=FF THEN
  52.       DO
  53.         SAY line||CR
  54.         count=count+1
  55.       END
  56.   END
  57. BREAK_C:
  58. BREAK_E:
  59. CALL CLOSE(f)
  60. /* RETURN(count); */
  61. EXIT;                           /* a little redundant, so sue me! */
  62.